package com.api.oa.mapper;

import com.api.oa.model.entity.YQNewsType;
import com.api.oa.model.vo.OaNoticeVo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface YQNewsTypeMapper {

    @Insert("insert into  yq_news_type  (" +
            "newsTypeId," +
            "newsTypeName," +
            "createdAt" +
            ") " +
            "values " +
            "(" +
            "#{entity.newsTypeId}," +
            "#{entity.newsTypeName}," +
            "#{entity.createdAt}" +
            ")")
    @Options(useGeneratedKeys = true, keyProperty = "newsTypeId", keyColumn = "id")
    Integer insert(@Param("entity") YQNewsType entity);


    @Update("update  yq_news_type  set " +
            "newsTypeId = #{entity.newsTypeId}," +
            "newsTypeName = #{entity.newsTypeName}," +
            "createdAt = #{entity.createdAt}" +
            " where newsTypeId = #{entity.newsTypeId}")
    Integer update(@Param("entity") YQNewsType entity);


    @Delete("delete from yq_news_type where newsTypeId=#{id}")
    void delete(@Param("id") Long id);


    @Select("<script> select * from  yq_news_type where 1=1 " +
            "<if test='keyWord!=null and keyWord!=\"\"'> newTypeName like ('%',#{keyWord},'%')</if>" +
            "</script>")
    List<YQNewsType> list(@Param("keyWord") String keyWord);



    @Select("select * from  yq_news_type ")
    List<YQNewsType> all();


    @Select("select * from  yq_news_type  where newsTypeId = #{id} limit 1")
    YQNewsType findOne(@Param("id") Long id);

}

